home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / INFO / DOSTIPS6.ZIP / DOSFIND < prev    next >
Text File  |  1987-03-02  |  4KB  |  103 lines

  1.                         Switched-On FIND
  2.       (PC Magazine Vol 6 No 6 March 31, 1987 User-to-User)
  3.  
  4.      The PC Lab Notes column on advanced FIND techniques (PC Magazine
  5. Vol 5 No 20) explained a method of using the DOS FOR...IN...DO command
  6. to handle FIND wildcards.  There aer two ways to improve this batch
  7. procedure.
  8.     The PC Lab Notes procedure lacked a method for specifying different
  9. combinations of wildcards (such as *.PAS), and couldn't add FIND
  10. switches such as /C or /V.  The WILDFILE.BAT allows both of these:
  11.  
  12. ECHO OFF
  13. IF %2!==! GOTO ERROR
  14. FOR %%A IN (%2) DO FIND%3 "%1" %%a
  15. GOTO END
  16. :ERROR
  17. ECHO The proper command syntax is:
  18. ECHO WILDFIND string filename [switches]
  19. :END
  20.  
  21.      The WILDFIND syntax is slightly different from the DOS FIND
  22. syntax.  First, the string to search for is not enclosed in quotation
  23. marks.  Second, the optional switches go at the end of the command line
  24. instead of immediately after the command name.  As with DOS, switches
  25. are separated from the filename by at least one space.
  26.      For example, to hunt for the string VAR1 in all files with the
  27. extension PAS, and then count but not display each occurrence of the
  28. string, type:
  29.  
  30. WILDFIND VAR1 *.PAS /C
  31.  
  32.      Editor's Note:  FIND and the FOR...IN...DO command are two of the
  33. most powerful DOS commands, especially when joined together.  However,
  34. each has drawbacks.  An annoying one is the awful /N numbering system.
  35. If you wanted a cleanly numbered list of all the *.TXT files on your
  36. disk, you might think you could type:
  37.  
  38. DIR *.TXT | FIND /N " " > NUMLIST
  39.  
  40. However, FIND won't put spaces between the numbers and the actual
  41. entries, and it won't align the columns properly if you're going from
  42. single-digit to double-digit numbers (or double to triple, if you
  43. have lots of files).
  44.     Worse, since the /N switch is really designed for searching through
  45. program source code, or phone directories, and not redirected DOS
  46. outputs, it will choke on empty lines and end up misnumbering
  47. everything.  A better way might be to get into DOS and redirect a
  48. directory of text files into a file called IN:
  49.  
  50. DIR *.TXT | FIND "-" > IN
  51.  
  52. and then run a small BASIC program NUMBER.BAS:
  53.  
  54. 100 OPEN "IN" FOR INPUT AS #1
  55. 110 OPEN "OUT" FOR OUTPUT AS #2
  56. 120 WHILE NOT EOF()
  57. 130 LINE INPUT #1,A$
  58. 140 PRINT #2,USING "###";A+1;
  59. 150 PRINT #2,CHR$(32);A$
  60. 160 A=A+1:WEND:CLOSE
  61.  
  62.      Another irksome thing about FIND is the "-----------" line it
  63. prints when displaying anything.  This is easy to get rid of by going
  64. into the code with DEBUG and replacing each hyphen with a backspace.
  65.      First, rename FIND.EXE to F, and load DEBUG:
  66.  
  67. REN FIND.EXE F
  68. DEBUG F
  69.  
  70. When you see the DEBUG "-" hyphen prompt, type RCX and hit the Enter
  71. key twice.  DEBUG will respond with something like:
  72.  
  73. CX 1903
  74. :
  75.  
  76. Then, when you see the hyphen prompt again, type:
  77.  
  78. S 100 L1903 "-----------"
  79.  
  80. (substituting the actual hex number DEBUG reported after the CX in the
  81. previous command, if it's different from 1903).  DEBUG will print an
  82. address that looks something like:
  83.  
  84. 2F71:19F7
  85.  
  86. Ignore the first four numbers (the ones to the left of the colon).
  87. Take the four rightmost hex numbers and enter them in place of the
  88. xxxx below:
  89.  
  90. E xxxx 8 8 8 8 8 8 8 8 8 8 8
  91.  
  92. For instance, you'd enter E 19F7 8 8 8 8 8 8 8 8 8 8 8 if DEBUG
  93. returned the 2F71:19F7 mentioned earlier.  Then type:
  94.  
  95. W
  96. Q
  97. REN F FIND.EXE
  98.  
  99. (hitting the Enter key after each line) and your new, patched FIND
  100. won't ever print the ----------- line again when displaying the
  101. strings you've searched for.
  102.  
  103.